import sys
from PySide.QtCore import *
from PySide.QtGui import *
 
class Form(QDialog):
    def __init__(self, parent=None):
        super(Form, self).__init__(parent)
        self.setWindowTitle("My Form")
        self.edit = QLineEdit("Write my name here..")
        self.button = QPushButton("Show Greetings")
        
        # Create layout and add widgets
        layout = QVBoxLayout()
        layout.addWidget(self.edit)
        layout.addWidget(self.button)
        
        # Set dialog layout
        self.setLayout(layout)

        self.button.clicked.connect(self.greetings)

    def greetings(self):
        msgBox = QMessageBox()
        msgBox.setText("Hello %s" % self.edit.text())
        msgBox.setInformativeText("Do you want to save your changes?")
        msgBox.setStandardButtons(QMessageBox.Cancel)
        msgBox.setDefaultButton(QMessageBox.Save)
        msgBox.exec_()

if __name__ == '__main__':

    # Create the Qt Application
    app = QApplication(sys.argv)

    # Create and show the form
    form = Form()
    form.show()

    #Run the main Qt loop
    sys.exit(app.exec_())
